var $ = getApp(), methods = require("../methods.js");
Page(Object.assign({}, methods, {
	data: {
        ispic:1,
        selectedDate:'',
        pics:[],
        id:0
	},
	_onLoad:function(){
        var that = this;
        var id = 0;
        if(that.options.id){
            id = that.options.id
        }
        if(!id){
            $.error("参数错误");
            return ;
        }
        this.setData({id:id});
		
    },
    ispicChange:function(e){
        var ispic = e.detail.value;
		this.setData({ispic:ispic})
	},
    handleDateChange: function (event) {
        const selectedDate = event.detail.value;
        console.log(selectedDate)
        this.setData({
            selectedDate: selectedDate,
        });
    },
	subform:function(e){
		var that = this;
		var info = e.detail.value;
		
		if(info.shuishen=='' || info.ganchang=="" || info.yonger==""){
			$.error('请输入钓点信息');return false;
		}
		
		// if(info.pics=='' && that.data.ispic==1){
		// 	$.error('请上传钓点图片');return false;
        // }
		
		if(that.data.selectedDate){
            info.diaohuotime = that.data.selectedDate
        }else{
            info.diaohuotime = "";
            $.error('请选择钓获时间');return false;
        }
		
	
		info.id = that.data.id;

        info.ispic = that.data.ispic;
        
		$.post("yuxun/yuhuoadd",{info:info},function(res){
			$.error(res.msg);
			setTimeout(function(){
                $.goback(true)
			},1000)
		},'提交中');
	},
    setshuishen:function(e){
		this.setData({'info.shuishen':e.detail.value})	
    },
    setganchang:function(e){
		this.setData({'info.ganchang':e.detail.value})	
    },
    setyonger:function(e){
		this.setData({'info.yonger':e.detail.value})	
    },

}))